<?
require_once("../config/dbconn.php");require_once("../config/usercls.php");require_once("../config/pagecls.php");
require_once("pwd1cls.php");
if($action=='del'){
	$db->delete("{$db_prefix}huikuan","id='$id'");
	echo "<script>location.href='huikuan_lst.php?pageno={$pageno}';</script>";exit();
}

if($act=='huikuan'){
	$msg='';
	if(trim($bankid)=='') $msg.="请选择汇款银行\\n";
	if(trim($ptype)=='') $msg.="请选择充值账户类型\\n";
	if(floatval($price)<=0) $msg.="请输入汇款金额\\n";
	if ($msg!=''){
		echo "<script>alert('$msg');history.back();</script>";exit();
	}
	//获取汇款银行信息
	$sqlb="select * from {$db_prefix}banks where id='$bankid'";
	$rsb=$db->get_one($sqlb);
	$bank=$rsb['bank'];$bankaddress=$rsb['bankaddress'];$bankno=$rsb['card'];$bankname=$rsb['bankname'];
	//插入数据库
	$dataArray['bankid']=$bankid;
	$dataArray['bank']=$bank;
	$dataArray['bankaddress']=$bankaddress;
	$dataArray['bankname']=$bankname;
	$dataArray['bankno']=$bankno;
	$dataArray['username']=$_SESSION['sys_username'];
	$dataArray['price']=floatval($price);
	$dataArray['ptype']=$ptype;
	$dataArray['state']=0;
	$dataArray['memo']=addslashes($memo);
	$dataArray['addtime']=$curtime;
	$dataArray['edittime']=0;
	$db->insert("{$db_prefix}huikuan",$dataArray);
	echo "<script>alert('银行汇款提交');location.href='huikuan_lst.php';</script>";exit();
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
		background-image: url(image1/bg-body.png);
}
td{
font-size:12px;
}
.red{
	color:#FF0000
}
-->
</style>

<link href="images/skin.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="17" height="29" valign="top" background="images/mail_leftbg1.png"><img src="images/left-top-right1.png" width="17" height="29" /></td>
    <td width="100%" height="29" valign="top" background="images/content-bg.gif"><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="left_topbg" id="table2">
      <tr>
        <td height="31"><div class="titlebt">银行汇款</div></td>
      </tr>
    </table></td>
    <td width="16" valign="top" background="images/mail_rightbg.png"><img src="images/nav-right-bg.png" width="16" height="29" /></td>
  </tr>
  <tr>
    <td height="71" valign="middle" background="images/mail_leftbg1.png">&nbsp;</td>
    <td valign="top" bgcolor="#F7F8F9"><table width="100%" height="138" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="13" valign="top">&nbsp;</td>
      </tr>
      <tr>
        <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="nowtable">
                <tr>
                  <td class="left_bt2"><form id="form1" name="form1" method="post" action="?act=huikuan">
                    <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#F7F8F9">
					<tbody bgcolor="#FFFFFF">
                      <tr>
                        <td colspan="3"><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="nowtable">
                            <tr>
                              <td class="left_bt2">&nbsp;&nbsp;&nbsp;&nbsp;<strong>申请银行汇款</strong></td>
                            </tr>
                        </table></td>
                      </tr>
                      <tr>
                        <td height="30" colspan="3"><table width="100%" height="120" border="0" cellpadding="0" cellspacing="0">
                            <tr>
                              <td height="30" align="center" class="left_txt"><div align="center" class="red">选择汇款银行</div></td>
                              <td height="30" class="left_txt"><?
				  $sqlb="select * from {$db_prefix}banks where 1";
				  $resultb=$db->query($sqlb);
				  while($rsb=$db->fetch_array($resultb)){
				  ?>
                                  <input type="radio" name="bankid" value="<?=$rsb['id']?>" <? if ($rs['bankid']==$rsb['id']) echo " checked"?>>
                                  <?=$rsb['bank']?>
                                  <br>
                                开户行地址：
                                <?=$rsb['bankaddress']?>
                                <br>
                                卡号：
                                <?=$rsb['card']?>
                                <br>
                                开户名：
                                <?=$rsb['bankname']?>
                                <br>
                                <?
				  }
				  $db->free_result($resultb);
				  ?>
                              </td>
                            </tr>
                            <tr>
                              <td height="30" align="center" class="left_txt">充值账户</td>
                              <td height="30" class="left_txt"><label>
                                <select name="ptype">
                                  <?
					foreach($hychongzhitypeary as $k1=>$v1){
						echo "<option value='{$k1}'";
						if ($rs['ptype']==$k1) echo " selected";
						echo ">{$v1}</option>";
					}
					?>
                                </select>
                                </label>
                                  <span class="red"> *</span></td>
                            </tr>
                            <tr>
                              <td height="30" align="center" class="left_txt">金额</td>
                              <td height="30" class="left_txt"><label>
                                <input name="price" type="text" id="price" size="10" value="<?=$rs['price']?>">
                                人民币<span class="red">*</span></label></td>
                            </tr>
                            <tr>
                              <td height="30" align="center" class="left_txt">说明</td>
                              <td height="30" class="left_txt"><label>
                                <textarea name="memo" cols="40" rows="6" id="memo"><?=stripslashes($rs['memo'])?>
                  </textarea>
                              </label></td>
                            </tr>
                        </table></td>
                      </tr>
                      <tr>
                        <td height="30" colspan="3">&nbsp;</td>
                      </tr>
                      <tr>
                        <td width="50%" height="30" align="right"><input name="id" type="hidden" id="id" value="<?=$id?>">
                            <input name="pageno" type="hidden" id="pageno" value="<?=$pageno?>">
                            <input type="submit" value="完成以上修改" name="B1" /></td>
                        <td width="6%" height="30" align="right">&nbsp;</td>
                        <td width="44%" height="30"><input type="reset" value="取消设置" name="B12" /></td>
                      </tr>
                      <tr>
                        <td height="30" colspan="3">&nbsp;</td>
                      </tr>
					  </tbody>
                    </table>
                  </form></td>
                </tr>
              </table></td>
            </tr>
            <tr>
              <td height="30"><table width="100%" height="60" border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <td height="30" align="center" bgcolor="#f2f2f2" >编号</td>
                  <td align="center" bgcolor="#f2f2f2" >银行</td>
                  <td align="center" bgcolor="#f2f2f2" >银行地址</td>
                  <td align="center" bgcolor="#f2f2f2" >卡号</td>
                  <td align="center" bgcolor="#f2f2f2" >开户名</td>
                  <td align="center" bgcolor="#f2f2f2" >金额</td>
                  <td align="center" bgcolor="#f2f2f2" >充值账户</td>
                  <td align="center" bgcolor="#f2f2f2" >状态</td>
                  <td align="center" bgcolor="#f2f2f2" >申请时间</td>
                  <td align="center" bgcolor="#f2f2f2" >审核时间</td>
                  <td height="30" align="center" bgcolor="#f2f2f2" >操作</td>
                  </tr>
  <?
  $query='';
  if ($action=='query'){
  	
  }
  $sql="select count(id) as c  from {$db_prefix}huikuan where username='".$_SESSION['sys_username']."'";
  if ($query!='') $sql.=$query;
  $rs=$db->get_one($sql);
  $page=new pagecls(20,intval($rs['c']));
  $sql="select * from {$db_prefix}huikuan where username='".$_SESSION['sys_username']."'";
  if ($query!='') $sql.=$query;
  $sql.=" order by id desc limit {$page->pastnum},{$page->pagesize}";
  $result=$db->query($sql);
  while($rs=$db->fetch_array($result)){
  ?>
                <tr>
                  <td align="center"><?=$rs['id']?></td>
                  <td align="center"><?=$rs['bank']?>                      </td>
                  <td align="center" ><?=$rs['bankaddress']?></td>
                  <td align="center" ><?=$rs['bankno']?></td>
                  <td align="center" ><?=$rs['bankname']?></td>
                  <td align="center" ><?=$rs['price']?></td>
                  <td align="center" class="red" ><?=$hypricetypeary[$rs['ptype']]?></td>
                  <td align="center" class="left_txt3" ><? if ($rs['state']==0) echo "等待审核";elseif ($rs['state']==1) echo "已经充值";elseif($rs['state']==2) echo "充值失败";?></td>
                  <td align="center" ><?=date("Y-m-d H:i:s",$rs['addtime'])?></td>
                  <td align="center" ><? if ($rs['edittime']>0) echo date("Y-m-d H:i:s",$rs['edittime'])?></td>
                  <td height="30" align="center" >
				  <a href="huikuan_view.php?id=<?=$rs['id']?>&pageno=<?=$page->pageno?>">查看</a>|<?
				  if ($rs['state']==0){
				  ?>
				  <a href="huikuan_add.php?id=<?=$rs['id']?>&pageno=<?=$page->pageno?>">修改</a>| <a href="?action=del&id=<?=$rs['id']?>&pageno=<?=$page->pageno?>">删除</a>
				  <?
				  }
				  ?>
				 </td>
                  </tr>
	<?
  }
  $db->free_result($result);
  ?>
              </table></td>
            </tr>
            
            <tr>
              <td height="30">&nbsp;</td>
            </tr>
            <tr>
              <td height="30" align="right">每页<?=$page->pagesize?>条 第<?=$page->pageno?>/<?=$page->pagenum?>页 共<?=$page->recnum?>条 <a href='?<?=$page->url?>1'><img src="image1/first.gif" border="0"></a>   <a href='?<?=$page->url.($page->pageno-1)?>'><img src="image1/back.gif" border="0"></a>  <a href='?<?=$page->url.($page->pageno+1)?>'><img src="image1/next.gif" border="0"></a>   <a href='?<?=$page->url.$page->pagenum?>'><img src="image1/last.gif" border="0"></a></td>
              </tr>
            <tr>
              <td height="30">&nbsp;</td>
            </tr>
          </table></td>
      </tr>
    </table></td>
    <td background="images/mail_rightbg.png">&nbsp;</td>
  </tr>
  <tr>
    <td valign="middle" background="images/mail_leftbg.png"><img src="images/buttom_left2.png" width="17" height="17" /></td>
      <td height="17" valign="top" background="images/buttom_bgs.png"><img src="images/buttom_bgs.png" width="17" height="17" /></td>
    <td background="images/mail_rightbg.png"><img src="images/buttom_right2.png" width="16" height="17" /></td>
  </tr>
</table>

</body>
</html>
